package system.samples;

import client.Client;
import client.ClientNavigator;
import client.Command;
import system.impl.CommandLineClient;

	public Command("Exit") Exit() {
	
		Command() {
			super("Exit");
		}
		
		private ClientNavigator navigator;
	
		public Exit(ClientNavigator navigator) {
			this();
			this.navigator = navigator;
		}
	
	
		@Override
		protected void doFunction() {
			Client client = getContext().getNavigator().getClient();
			if(client instanceof CommandLineClient) {
				String exitString = "exiting";
				if(getArguments() != null)
					exitString += ": " + getArguments();
				((CommandLineClient)client).println(exitString);
			}
			navigator.getClient().exit();
		}
	

	}

}
